package com.ruozedata.bigdata.lesson05

import scala.collection.mutable

object MapApp {

    def main(args: Array[String]): Unit = {

        val a = Map("pk" -> 1, "ruoze" -> 28)
        a("pk")
        println(a.contains("pks"))

        for ((k,v) <- a) {
            println(k,v)
        }

        for (ele <- a.keys) {
            println(ele)
        }

        a.foreach(println)

        // Option Some None
        println(a.get("pk").get)
        println(a.get("pk1").getOrElse(0))
        println(a.getOrElse("pk1", 0))

        import scala.collection.mutable._
        val a1 = Map("pk"-> 1)
        val b = mutable.HashMap[String, Int]()
        println(a.updated("pk", 13))
        a1 += ("xx"->12)
        println(a1)
    }
}
